﻿using UnityEngine;
using System.Collections.Generic;

public class SliceManager : MonoBehaviour 
{
	public MeshRenderer[] slices = new MeshRenderer[3];
	
	private BallColors ballColors;
	
	void Start()
	{
		ballColors = (BallColors) GetComponent("BallColors");
	}
	
	public void SetSlices(List<Color> newSlices)
	{
		if (slices.Length == newSlices.Count)
		{
			for (int i = 0; i < slices.Length; i++)
			{				
				slices[i].material.color = newSlices[i];
			}
		}
		else
		{
			Debug.LogError("Slice data mismatch");
		}
	}
		
	public void AddColorToSlice(GameObject slice, Color color)
	{
		Color newColor = ballColors.NormalizeColor(slice.renderer.material.color + color);
			
		slice.renderer.material.color = newColor;		
	}
}
